PATHMac OS 8 and 9 Developer Documentation > Human Interface Toolbox > Dialog Manager >

Mac OS 8 Dialog Manager Reference

Mac OS 8 Dialog Manager Reference


Manipulating Items in Dialog Boxes and Alert Boxes

The following Dialog Manager functions for manipulating items in dialog boxes and alert boxes are new, changed, or not recommended with Appearance Manager 1.0:


GetDialogItemAsControl

Obtains the control handle for a dialog item in an embedding hierarchy.

pascal OSErr GetDialogItemAsControl (
                     DialogPtr inDialog,
                     SInt16 inItemNo,
                     ControlHandle *outControl);
inDialog
A pointer to the dialog box to examine.
inItemNo
The position of an item in the dialog box's item list.
outControl
A pointer to a control handle that, on return, refers to the embedded control.
function result
A result code; see Dialog Manager Result Codes . The Control Manager result code errItemNotControl indicates that the specified dialog item is not a control.

DISCUSSION

When an embedding hierarchy is established, GetDialogItemAsControl produces a handle to the embedded controls (except Help items). It should be used instead of GetDialogItem when an embedding hierarchy is established.


VERSION NOTES

Available with Appearance Manager 1.0 and later.


GetDialogItem

Obtains a handle to a dialog item.

pascal void GetDialogItem (
                     DialogPtr theDialog,
                     short itemNo,
                     short *itemType,
                     Handle *item,
                     Rect *box);
theDialog
A pointer to the dialog box to examine.
itemNo
The position of the item in the dialog box's item list resource; use FindDialogItem to determine this value.
itemType
A pointer to a short value. On return, the value identifies the item type of the dialog item requested in the itemNo parameter. See Inside Macintosh: Macintosh Toolbox Essentials for a discussion of dialog item types.
item
A pointer to an item handle. On return the handle refers to the item specified in the itemNo parameter or, for application-defined draw functions, a pointer (coerced to a handle) to the draw function.
box
A pointer to a rectangle. On return, the rectangle specifies the display rectangle (described in coordinates local to the dialog box), for the item specified in the itemNo parameter.

DISCUSSION

The GetDialogItem function produces the item type, a handle to the item (or, for application-defined draw functions, the function pointer), and the display rectangle for a specified item in an item list resource. When a control hierarchy is present in the dialog box, GetDialogItem gets the appropriate information (for example, a text handle) from the controls. If you wish to get a control handle for a dialog item in an embedding hierarchy, see GetDialogItemAsControl .

You should call GetDialogItem before calling functions such as SetDialogItemText that need a handle to a dialog item.


SEE ALSO

SetDialogItem .


VERSION NOTES

Changed with Appearance Manager 1.0 to support retrieving item information from controls.


SetDialogItem

Sets or changes information for a dialog item.

pascal void SetDialogItem (
                     DialogPtr theDialog,
                     short itemNo,
                     short itemType,
                     Handle item,
                     const Rect *box);
theDialog
A pointer to the dialog box containing the dialog item.
itemNo
The position of the item in the dialog box's item list resource; use FindDialogItem to determine this value.
itemType
A short value. Pass an item type constant identifying the dialog item specified in the itemNo parameter. See Inside Macintosh: Macintosh Toolbox Essentials for a discussion of dialog item types. When an embedding hierarchy is established, only the kItemDisableBit item type constant is honored.
item
Either a handle to the dialog item specified in the itemNo parameter or, for a custom dialog item, a pointer (coerced to a handle) to an application-defined item drawing function. When an embedding hierarchy is established, the item parameter is ignored unless you pass a universal procedure pointer to an application-defined item draw function .
box
A pointer to the display rectangle (in local coordinates) for the item specified in the itemNo parameter. If you set the control rectangle on an item when an embedding hierarchy is present, SetDialogItem will move and resize the item appropriately for you, on return.

DISCUSSION

The SetDialogItem function sets the item specified by the itemNo parameter for the specified dialog box. If an embedding hierarchy exists, however, you cannot change the type or handle of an item, although application-defined item drawing functions can still be set.


SEE ALSO

GetDialogItem .


VERSION NOTES

Changed with Appearance Manager 1.0 to work with embedding hierarchies.


GetDialogKeyboardFocusItem

When the Appearance Manager is available and an embedding hierarchy is established, you should call the Control Manager function GetKeyboardFocus instead of GetDialogKeyboardFocusItem to return the item number of the item in a dialog box that has keyboard focus.


VERSION NOTES

Not recommended with Appearance Manager 1.0 and later.


FindDialogItem

Determines the item number of an item at a particular location in a dialog box.

pascal short FindDialogItem (
                     DialogPtr theDialog,
                     Point thePt);
theDialog
A pointer to a dialog structure.
thePt
The point (in local coordinates) where the mouse-down event occurred.
function result
When an embedding hierarchy is established, the FindDialogItem function returns the deepest control selected by the user corresponding to the point specified in the thePt parameter. When an embedding hierarchy does not exist, FindDialogItem performs a linear search of the item list resource and returns a number corresponding to the hit item's position in the item list resource. For example, it returns 0 for the first item in the item list, 1 for the second, and 2 for the third. If the mouse is not over a dialog item, FindDialogItem returns -1.

DISCUSSION

The function FindDialogItem is useful for changing the cursor when the user moves the cursor over a particular item.

To get the proper item number before calling the GetDialogItem GetDialogItem function or the SetDialogItem function, add 1 to the result of FindDialogItem , as shown here:

theItem = FindDialogItem(theDialog, thePoint) + 1;

Note that FindDialogItem returns the item number of disabled items as well as enabled items.


VERSION NOTES

Changed with Appearance Manager 1.0 to support embedding hierarchies.


MoveDialogItem

Moves a dialog item to a specified location in a window.

pascal OSErr MoveDialogItem (
                     DialogPtr inDialog,
                     SInt16 inItemNo,
                     SInt16 inHoriz,
                     SInt16 inVert);
inDialog
A pointer to the dialog box containing the item to move.
inItemNo
The position of the item in the dialog box's item list resource; use FindDialogItem to determine this value.
inHoriz
The new horizontal coordinate for the dialog item.
inVert
The new vertical coordinate for the dialog item.
function result
A result code; see Dialog Manager Result Codes .

DISCUSSION

The MoveDialogItem function moves a dialog item to a specified location in a window. MoveDialogItem ensures that if the item is a control, the control rectangle and the dialog item rectangle (maintained by the Dialog Manager) are always the same.


VERSION NOTES

Available with Appearance Manager 1.0 and later.


SizeDialogItem

Sizes a dialog item.

pascal OSErr SizeDialogItem (
                     DialogPtr inDialog,
                     SInt16 inItemNo,
                     SInt16 inWidth,
                     SInt16 inHeight);
inDialog
A pointer to the dialog box containing the item to be resized.
inItemNo
The position of the item in the dialog box's item list resource; use FindDialogItem to determine this value.
inWidth
The new width (in pixels) of the dialog item's control rectangle.
inHeight
The new height (in pixels) of the dialog item's control rectangle.
function result
A result code; see Dialog Manager Result Codes .

DISCUSSION

The SizeDialogItem function resizes a dialog item to a specified size. If the dialog item is a control, the control rectangle and the dialog item rectangle (maintained by the Dialog Manager) are always the same.


VERSION NOTES

Available with Appearance Manager 1.0 and later.


AutoSizeDialog

Automatically resizes static text fields and their dialog boxes to accommodate changed static text.

pascal OSErr AutoSizeDialog (DialogPtr inDialog);
inDialog
A pointer to a dialog box.
function result
A result code; see Dialog Manager Result Codes .

DISCUSSION

The AutoSizeDialog function is useful in situations such as localization, where the size of a static text field (and the dialog box that contains it) may need to be altered to accommodate a change in the size of the static text.

For each static text item AutoSizeDialog finds in the item list resource, it adjusts the static text field and the bottom of the dialog box window to accommodate the text. Any items below a static text field are moved down. If the dialog box is visible when this function is called, it is hidden, resized, and then shown. If the dialog box has enough room to show the text as is, no resizing is done.

Note that the AutoSizeDialog function does not process update events for your dialog box, so your program must call the DrawDialog function or the DialogSelect function to process the update event generated from showing the window.


VERSION NOTES

Available with Appearance Manager 1.0 and later.


AppendDialogItemList

Adds items to an existing dialog box while your program is running.

pascal OSErr AppendDialogItemList (
                     DialogPtr dialog,
                     SInt16 ditlID,
                     DITLMethod method);
dialog
A pointer to the dialog box to which the items in the item list resource specified in the ditlID parameter are to be appended.
ditlID
The resource ID of the item list resource whose items are to be appended to the dialog box specified in the dialog parameter.
method
The manner in which the new items are to be displayed in the dialog box.
If you use the overlayDITL constant, AppendDialogItemList superimposes the appended items over the dialog box by interpreting the coordinates of the display rectangles for the appended items (as specified in their item list resource) as local coordinates within the dialog box.
If you use the appendDITLRight constant, AppendDialogItemList appends the items to the right of the dialog box by positioning the display rectangles of the appended items relative to the upper-right coordinate of the dialog box. The AppendDialogItemList function automatically expands the dialog box to accommodate the new dialog items. If you use the appendDITLBottom constant, AppendDialogItemList appends the items to the bottom of the dialog box by positioning the display rectangles of the appended items relative to the lower-left coordinate of the dialog box. The AppendDialogItemList function automatically expands the dialog box to accommodate the new dialog items. You can append a list of items relative to an existing item by passing a negative number. The absolute value of this number is interpreted as the item in the dialog box relative to which the new items are to be positioned. For example, if you pass -2, the display rectangles of the appended items are offset relative to the upper-left corner of item number 2 in the dialog box.
function result
A result code; see Dialog Manager Result Codes .

DISCUSSION

To be Appearance-compliant, your program should use the AppendDialogItemList function rather than the AppendDITL function. Unlike AppendDITL , the AppendDialogItemList function takes a 'DITL' resource ID instead of a handle as the parameter describing the dialog item list to be appended, and it properly appends entries from a dialog font table ('dftb') resource, if there is a 'dftb' resource with the same resource ID as the 'DITL' resource.

The AppendDialogItemList function adds the items in the item list resource specified in the parameter ditlID to the items of a dialog box. This is especially useful if several dialog boxes share a single item list resource, because you can use AppendDialogItemList to add items that are appropriate for individual dialog boxes. Your application can use the Resource Manager function GetResource to get a handle to the item list resource whose items you wish to add.

You typically create an invisible dialog box, call the AppendDialogItemList function, then make the dialog box visible by using the Window Manager function ShowWindow .


VERSION NOTES

Available with Appearance Manager 1.0 and later.


© 1998 Apple Computer, Inc. - (Last Updated 19 Nov 98)